package com.sz.designpattern.behavior11.iterator;

public class DeliveryIterator implements Iterator{
    protected Aggregate aggregate;
    protected int index;

    public DeliveryIterator(Aggregate aggregate) {
        this.aggregate = aggregate;
    }

    @Override
    public boolean hasNext() {
        if (index < aggregate.size()){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Object next() {
        return aggregate.get(index++);
    }
}
